﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Register.ascx.vb" Inherits="FrontEnd_Control_Users_Register" %>

<%@ Register Assembly="ValidationTextBox" Namespace="ValidationTextBox.CustomControls"
    TagPrefix="cc1" %>
<%@ Register Assembly="ValidationDropdownlist" Namespace="ValidationDropdownlist.CustomControls"
    TagPrefix="cc2" %>
<script type="text/javascript">
    function ajaxJquery() {
        $(function () {

            $('#<%= txtCode.ClientID  %>').realperson();

            $(":input").keypress(function (e) {
                if (e.keyCode == 13) {

                    $("#<%=btnRegister.ClientID()%>").click();
                    return false;
                }
            });

            $("#<%= hplDangNhap.ClientID %>").click(function () {
                window.parent.OpenFormLogin();
                self.parent.tb_remove();
                return false;

            });

            $("#<%= btnRegister.ClientID %>").click(function () {
                if (validateFormInputs() == true) {
                    if (CheckCap() == true) {
                        return checkAgreement();
                    } else {

                        return false;
                    }
                } else {

                    return false;
                }
            });


            $("#<%= btnRegister.ClientID %>").click(function () {

                if (validateFormInputs('reg') == true) {
                    if (CheckCap() == true) {
                        return checkAgreement();
                    } else {

                        return false;
                    }

                } else {
                    return false;
                }
            });

            //Kiem tra trung
            $("#<%= txtUsername.ClientID %>").focusout(function () {

                var sName = $(this).val();
                $.ajax({
                    type: "POST", //Phuong thuc truyen du lieu luon la POST
                    url: '<%=ResolveUrl("~/Services/swCheckData.asmx/CheckName")%>',
                    data: "{'strName': '" + sName + "'}", //thong so truyen vao
                    dataType: "", //kieu du lieu tra ve
                    contentType: "application/json; charset=utf-8",
                    success: function (result) {

                        var resultReturn = eval("(" + result.d + ")");

                        if (resultReturn == "0") {
                            alert("Người dùng đã tồn tại hãy chọn tên khác.");
                            // $("#<%= txtUsername.ClientID %>").select();
                            // $("#<%= txtUsername.ClientID %>").focus();



                        } else {
                            //     alert("Tên người dùng hợp lệ bạn có thể sử dụng tên này.");

                        }

                    }, //ham thuc thi neu thanh cong    
                    error: function (XMLHttpRequest, textStatus, errorThrown) {

                    } //ham thuc thi neu loi xay ra.

                });
            });
        });
    }

    function init() {
        self.parent.tb_remove();
        parent.location.reload(true);
    }


    function checkAgreement() {
        var elem = document.getElementById('<%= chkAgree.ClientID %>');

        if (elem.checked) {
            return true;
        }
        else {
            alert('Vui lòng nhấn chọn Đồng ý.')
            return false;
        }
    }

    function CheckCap() {
        var elem = $('.hasRealPerson').val();
        var haselem = $('.realperson-hash').val();

        if (rpHash(elem) == haselem) {
            return true;
        }
        else {

            alert('Vui lòng nhập đúng mã xác thực.');
            $('.hasRealPerson').select();
            $('.hasRealPerson').focus();
            return false;
        }
    }
    function rpHash(value) {
        var hash = 5381;
        for (var i = 0; i < value.length; i++) {
            hash = ((hash << 5) + hash) + value.charCodeAt(i);
        }
        return hash;
    }

    // Hàm dùng để Reset lại giá trị ban đầu cho  form
    function resetForm() {
        $("div[id*=edit] input[type=text]").val("");
        $("div[id*=edit] textarea").val("");
        $("div[id*=edit] select").attr('selectedIndex', 0);
        return true;
    }

</script>
<div class="box_conrent_main" style="width:99%" >
    <div class="fRegister_head_link">
        <span>Đăng ký</span> hoặc
        <asp:HyperLink ID="hplDangNhap" runat="server" Text=" Đăng nhập"></asp:HyperLink>
    </div>



    <div class="bgmid_conrent_main">
        <div class="content_viewinfo">
            <!-- note form -->
            <div class="note_form">
                Các trường đánh dấu <span>*</span> là bắt buộc</div>
            <!-- note form -->
            <!-- line tip form -->
            <div class="divline_form">
                Thông tin dùng đăng nhập website
            </div>
            <!-- end line tip form -->
            <table class="tableinfo" width="100%" border="0" cellspacing="4" cellpadding="1">
                <tr class="rowinfo">
                    <td class="label" width="40%">
                        Tên đăng nhập:
                    </td>
                    <td width="60%" class="input_text">
                        <cc1:ValidationTextBox ID="txtUsername" CssClass="TextBox" Group="reg" AssociatedLableText="tên đăng nhập.Tối đa 16 ký tự,không gồm ký tự đặc biệt,không trùng với tên đăng nhập đã dùng."
                            runat="server" Text="" MaxLength="16" DataType="requiredAndAlphaNumeric"></cc1:ValidationTextBox>
                        <span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Mật khẩu:
                    </td>
                    <td class="input_text">
                        <cc1:ValidationTextBox ID="txtPassword" Group="reg" AssociatedLableText="mật khẩu"
                            CssClass="TextBox" runat="server" Text="" TextMode="Password" MaxLength="16"
                            DataType="requiredAndAlphaNumeric "></cc1:ValidationTextBox>
                        <span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Xác nhận mật khẩu:
                    </td>
                    <td class="input_text">
                        <cc1:ValidationTextBox ID="txtRepassword" Group="reg" AssociatedLableText="mật khẩu xác nhận"
                            CssClass="TextBox" runat="server" Text="" TextMode="Password" Compage="true"
                            MaxLength="16" DataType="requiredAndAlphaNumeric" CompareOperator="Equal" CompareTo="ContentPlaceHolder1_Register1_txtPassword"></cc1:ValidationTextBox>
                        <span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Email:
                    </td>
                    <td class="input_text">
                        <cc1:ValidationTextBox ID="txtEmail" CssClass="TextBox" AssociatedLableText="Email" runat="server" Text="" MaxLength="50"
                            CustomPattern="Email" DataType="requiredCustom" />
                        <span>*</span>
                    </td>
                </tr>
            </table>
            <div class="divline_form">
            </div>
            <!-- line tip form -->
            <div class="divline_form">
                Thông tin Liên hệ
            </div>
            <!-- end line tip form -->
            <table class="tableinfo" width="100%" border="0" cellspacing="4" cellpadding="1">
                <tr class="rowinfo">
                    <td class="label" width="40%">
                        Họ :
                    </td>
                    <td width="60%" class="input_text">
                        <span>
                            <cc1:ValidationTextBox ID="txtFist" CssClass="TextBox" Group="reg" AssociatedLableText="họ"
                                Width="50px" MaxLength="16" runat="server" DataType="required"></cc1:ValidationTextBox></span>
                        &nbsp; Tên <span>
                            <cc1:ValidationTextBox ID="txtLastname" MaxLength="16" Width="50px" Group="reg" AssociatedLableText="tên"
                                CssClass="TextBox" runat="server" DataType="required"></cc1:ValidationTextBox></span>
                        <span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Ngày sinh:
                    </td>
                    <td class="input_text">
                        <span>
                            <cc2:ValidationDropdownlist ID="ddlDay" Group="reg" AssociatedLableText="ngày" CssClass="DropDownList"
                                Width="60" runat="server" DataType="required">
                            </cc2:ValidationDropdownlist>
                        </span>&nbsp; <span>
                            <cc2:ValidationDropdownlist ID="ddlMonth" Group="reg" AssociatedLableText="tháng"
                                CssClass="DropDownList" Width="60" runat="server" DataType="required">
                            </cc2:ValidationDropdownlist>
                        </span>&nbsp; <span>
                            <cc2:ValidationDropdownlist ID="ddlYear" Group="reg" AssociatedLableText="năm" CssClass="DropDownList"
                                Width="60" runat="server" DataType="required">
                            </cc2:ValidationDropdownlist>
                        </span><span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Giới tính:
                    </td>
                    <td class="input_text">
                        <cc2:ValidationDropdownlist ID="ddlGender" Group="reg" AssociatedLableText="giới tính"
                            runat="server" CssClass="TextBox" Width="100px" DataType="required">
                            <asp:ListItem Value="0">---Chọn---</asp:ListItem>
                            <asp:ListItem Value="1">Nam</asp:ListItem>
                            <asp:ListItem Value="2">Nữ</asp:ListItem>
                        </cc2:ValidationDropdownlist>
                        <span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Địa chỉ:
                    </td>
                    <td class="input_text">
                        <cc1:ValidationTextBox ID="txtDiaChi" runat="server" Group="reg" AssociatedLableText="địa chỉ"
                            CssClass='TextBox' DataType="required"></cc1:ValidationTextBox>
                        <span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Tỉnh\Thành Phố:
                    </td>
                    <td class="input_text">
                        <cc2:ValidationDropdownlist ID="ddlKhuVuc" Group="reg" AssociatedLableText="khu vực"
                            runat="server" Width="145px" CssClass='DropDownList' DataType="required">
                        </cc2:ValidationDropdownlist>
                        <span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Điện thoại:
                    </td>
                    <td class="input_text">
                        <cc1:ValidationTextBox ID="txtDienThoai" runat="server" Group="reg" AssociatedLableText="điện thoại"
                            CssClass='TextBox' DataType="required"></cc1:ValidationTextBox>
                        <span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Điện thoại khác:
                    </td>
                    <td class="input_text">
                        <cc1:ValidationTextBox ID="txtDienThoaiKhac" runat="server" CssClass='TextBox'></cc1:ValidationTextBox>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        Mã xác thực:
                    </td>
                    <td class="input_text">
                        <cc1:ValidationTextBox ID="txtCode" runat="server" Group="reg" AssociatedLableText="mã xác thực"
                            CssClass="TextBox" DataType="required" /><span>*</span>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        &nbsp;
                    </td>
                    <td class="input_text">
                        <asp:CheckBox ID="chkAgree" Text="" runat="server" />
                        Đồng ý với <b><a href="<%=ResolveUrl("~/thoa-thuan-rieng-tu.html")%>"
                            target="_blank">thỏa thuận sử dụng </a></b>
                    </td>
                </tr>
                <tr class="rowinfo">
                    <td class="label">
                        &nbsp;
                    </td>
                    <td class="input_text">
                        <asp:Button ID="btnRegister" runat="server" Text=" Đăng ký " CausesValidation="true"
                            CssClass="buy button" />
                       <div class="space10"> &nbsp; </div>
                        <input type="reset" class="buy button" value="Đặt lại" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="bgbottom_conrent_main">
    </div>
</div>
<!-- end Box ReGis -->
<div style="display: none">
    <asp:HiddenField ID="Ablage" Value="abc" runat="server" />
</div>
